﻿using System;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbOsnapOverrule : OdRxOverrule
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbOsnapOverrule(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbOsnapOverrule_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbOsnapOverrule obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbOsnapOverrule()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbOsnapOverrule(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public OdDbOsnapOverrule() : this(TD_DbPINVOKE.new_OdDbOsnapOverrule(), MemoryManager.GetMemoryManager().GetCurrentTransaction() == null)
		{
			MemoryTransaction currentTransaction = MemoryManager.GetMemoryManager().GetCurrentTransaction();
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdDbOsnapOverrule(this.swigCPtr.Handle, true));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			this.SwigDirectorConnect();
		}

		public new static OdDbOsnapOverrule cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbOsnapOverrule_cast(OdRxObject.getCPtr(pObj));
			OdDbOsnapOverrule result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbOsnapOverrule)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbOsnapOverrule)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbOsnapOverrule)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbOsnapOverrule_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(this.SwigDerivedClassHasMethod("isA", OdDbOsnapOverrule.swigMethodTypes1) ? TD_DbPINVOKE.OdDbOsnapOverrule_isASwigExplicitOdDbOsnapOverrule(this.swigCPtr) : TD_DbPINVOKE.OdDbOsnapOverrule_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(this.SwigDerivedClassHasMethod("queryX", OdDbOsnapOverrule.swigMethodTypes0) ? TD_DbPINVOKE.OdDbOsnapOverrule_queryXSwigExplicitOdDbOsnapOverrule(this.swigCPtr, OdRxClass.getCPtr(protocolClass)) : TD_DbPINVOKE.OdDbOsnapOverrule_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdDbOsnapOverrule createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbOsnapOverrule_createObject();
			OdDbOsnapOverrule result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbOsnapOverrule)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbOsnapOverrule)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbOsnapOverrule)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getOsnapPoints(OdDbEntity pSubject, OsnapMode osnapMode, IntPtr gsSelectionMark, OdGePoint3d pickPoint, OdGePoint3d lastPoint, OdGeMatrix3d xWorldToEye, OdGePoint3dArray snapPoints)
		{
			OdResult result = (OdResult)(this.SwigDerivedClassHasMethod("getOsnapPoints", OdDbOsnapOverrule.swigMethodTypes3) ? TD_DbPINVOKE.OdDbOsnapOverrule_getOsnapPointsSwigExplicitOdDbOsnapOverrule__SWIG_0(this.swigCPtr, OdDbEntity.getCPtr(pSubject), (int)osnapMode, gsSelectionMark, OdGePoint3d.getCPtr(pickPoint), OdGePoint3d.getCPtr(lastPoint), OdGeMatrix3d.getCPtr(xWorldToEye), OdGePoint3dArray.getCPtr(snapPoints)) : TD_DbPINVOKE.OdDbOsnapOverrule_getOsnapPoints__SWIG_0(this.swigCPtr, OdDbEntity.getCPtr(pSubject), (int)osnapMode, gsSelectionMark, OdGePoint3d.getCPtr(pickPoint), OdGePoint3d.getCPtr(lastPoint), OdGeMatrix3d.getCPtr(xWorldToEye), OdGePoint3dArray.getCPtr(snapPoints)));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getOsnapPoints(OdDbEntity pSubject, OsnapMode osnapMode, IntPtr gsSelectionMark, OdGePoint3d pickPoint, OdGePoint3d lastPoint, OdGeMatrix3d xWorldToEye, OdGePoint3dArray snapPoints, OdGeMatrix3d insertionMat)
		{
			OdResult result = (OdResult)(this.SwigDerivedClassHasMethod("getOsnapPoints", OdDbOsnapOverrule.swigMethodTypes4) ? TD_DbPINVOKE.OdDbOsnapOverrule_getOsnapPointsSwigExplicitOdDbOsnapOverrule__SWIG_1(this.swigCPtr, OdDbEntity.getCPtr(pSubject), (int)osnapMode, gsSelectionMark, OdGePoint3d.getCPtr(pickPoint), OdGePoint3d.getCPtr(lastPoint), OdGeMatrix3d.getCPtr(xWorldToEye), OdGePoint3dArray.getCPtr(snapPoints), OdGeMatrix3d.getCPtr(insertionMat)) : TD_DbPINVOKE.OdDbOsnapOverrule_getOsnapPoints__SWIG_1(this.swigCPtr, OdDbEntity.getCPtr(pSubject), (int)osnapMode, gsSelectionMark, OdGePoint3d.getCPtr(pickPoint), OdGePoint3d.getCPtr(lastPoint), OdGeMatrix3d.getCPtr(xWorldToEye), OdGePoint3dArray.getCPtr(snapPoints), OdGeMatrix3d.getCPtr(insertionMat)));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isContentSnappable(OdDbEntity pSubject)
		{
			bool result = this.SwigDerivedClassHasMethod("isContentSnappable", OdDbOsnapOverrule.swigMethodTypes5) ? TD_DbPINVOKE.OdDbOsnapOverrule_isContentSnappableSwigExplicitOdDbOsnapOverrule(this.swigCPtr, OdDbEntity.getCPtr(pSubject)) : TD_DbPINVOKE.OdDbOsnapOverrule_isContentSnappable(this.swigCPtr, OdDbEntity.getCPtr(pSubject));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private void SwigDirectorConnect()
		{
			if (this.SwigDerivedClassHasMethod("queryX", OdDbOsnapOverrule.swigMethodTypes0))
			{
				this.swigDelegate0 = new OdDbOsnapOverrule.SwigDelegateOdDbOsnapOverrule_0(this.SwigDirectorqueryX);
			}
			if (this.SwigDerivedClassHasMethod("isA", OdDbOsnapOverrule.swigMethodTypes1))
			{
				this.swigDelegate1 = new OdDbOsnapOverrule.SwigDelegateOdDbOsnapOverrule_1(this.SwigDirectorisA);
			}
			if (this.SwigDerivedClassHasMethod("isApplicable", OdDbOsnapOverrule.swigMethodTypes2))
			{
				this.swigDelegate2 = new OdDbOsnapOverrule.SwigDelegateOdDbOsnapOverrule_2(this.SwigDirectorisApplicable);
			}
			if (this.SwigDerivedClassHasMethod("getOsnapPoints", OdDbOsnapOverrule.swigMethodTypes3))
			{
				this.swigDelegate3 = new OdDbOsnapOverrule.SwigDelegateOdDbOsnapOverrule_3(this.SwigDirectorgetOsnapPoints__SWIG_0);
			}
			if (this.SwigDerivedClassHasMethod("getOsnapPoints", OdDbOsnapOverrule.swigMethodTypes4))
			{
				this.swigDelegate4 = new OdDbOsnapOverrule.SwigDelegateOdDbOsnapOverrule_4(this.SwigDirectorgetOsnapPoints__SWIG_1);
			}
			if (this.SwigDerivedClassHasMethod("isContentSnappable", OdDbOsnapOverrule.swigMethodTypes5))
			{
				this.swigDelegate5 = new OdDbOsnapOverrule.SwigDelegateOdDbOsnapOverrule_5(this.SwigDirectorisContentSnappable);
			}
			TD_DbPINVOKE.OdDbOsnapOverrule_director_connect(this.swigCPtr, this.swigDelegate0, this.swigDelegate1, this.swigDelegate2, this.swigDelegate3, this.swigDelegate4, this.swigDelegate5);
		}

		private bool SwigDerivedClassHasMethod(string methodName, Type[] methodTypes)
		{
			MethodInfo method = base.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, methodTypes, null);
			return method.DeclaringType.IsSubclassOf(typeof(OdDbOsnapOverrule));
		}

		private IntPtr SwigDirectorqueryX(IntPtr protocolClass)
		{
			return OdRxObject.getCPtr(this.queryX((OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(protocolClass, false))).Handle;
		}

		private IntPtr SwigDirectorisA()
		{
			return OdRxClass.getCPtr(this.isA()).Handle;
		}

		private bool SwigDirectorisApplicable(IntPtr pOverruledSubject)
		{
			return this.isApplicable(Teigha.Core.Helpers.odrxCreateObjectInternal(pOverruledSubject, false));
		}

		private int SwigDirectorgetOsnapPoints__SWIG_0(IntPtr pSubject, int osnapMode, IntPtr gsSelectionMark, IntPtr pickPoint, IntPtr lastPoint, IntPtr xWorldToEye, IntPtr snapPoints)
		{
			return (int)this.getOsnapPoints((OdDbEntity)Teigha.Core.Helpers.odrxCreateObjectInternal(pSubject, false), (OsnapMode)osnapMode, gsSelectionMark, new OdGePoint3d(pickPoint, false), new OdGePoint3d(lastPoint, false), new OdGeMatrix3d(xWorldToEye, false), new OdGePoint3dArray(snapPoints, false));
		}

		private int SwigDirectorgetOsnapPoints__SWIG_1(IntPtr pSubject, int osnapMode, IntPtr gsSelectionMark, IntPtr pickPoint, IntPtr lastPoint, IntPtr xWorldToEye, IntPtr snapPoints, IntPtr insertionMat)
		{
			return (int)this.getOsnapPoints((OdDbEntity)Teigha.Core.Helpers.odrxCreateObjectInternal(pSubject, false), (OsnapMode)osnapMode, gsSelectionMark, new OdGePoint3d(pickPoint, false), new OdGePoint3d(lastPoint, false), new OdGeMatrix3d(xWorldToEye, false), new OdGePoint3dArray(snapPoints, false), new OdGeMatrix3d(insertionMat, false));
		}

		private bool SwigDirectorisContentSnappable(IntPtr pSubject)
		{
			return this.isContentSnappable((OdDbEntity)Teigha.Core.Helpers.odrxCreateObjectInternal(pSubject, false));
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		private OdDbOsnapOverrule.SwigDelegateOdDbOsnapOverrule_0 swigDelegate0;

		private OdDbOsnapOverrule.SwigDelegateOdDbOsnapOverrule_1 swigDelegate1;

		private OdDbOsnapOverrule.SwigDelegateOdDbOsnapOverrule_2 swigDelegate2;

		private OdDbOsnapOverrule.SwigDelegateOdDbOsnapOverrule_3 swigDelegate3;

		private OdDbOsnapOverrule.SwigDelegateOdDbOsnapOverrule_4 swigDelegate4;

		private OdDbOsnapOverrule.SwigDelegateOdDbOsnapOverrule_5 swigDelegate5;

		private static Type[] swigMethodTypes0 = new Type[]
		{
			typeof(OdRxClass)
		};

		private static Type[] swigMethodTypes1 = new Type[0];

		private static Type[] swigMethodTypes2 = new Type[]
		{
			typeof(OdRxObject)
		};

		private static Type[] swigMethodTypes3 = new Type[]
		{
			typeof(OdDbEntity),
			typeof(OsnapMode),
			typeof(IntPtr),
			typeof(OdGePoint3d),
			typeof(OdGePoint3d),
			typeof(OdGeMatrix3d),
			typeof(OdGePoint3dArray)
		};

		private static Type[] swigMethodTypes4 = new Type[]
		{
			typeof(OdDbEntity),
			typeof(OsnapMode),
			typeof(IntPtr),
			typeof(OdGePoint3d),
			typeof(OdGePoint3d),
			typeof(OdGeMatrix3d),
			typeof(OdGePoint3dArray),
			typeof(OdGeMatrix3d)
		};

		private static Type[] swigMethodTypes5 = new Type[]
		{
			typeof(OdDbEntity)
		};

		public delegate IntPtr SwigDelegateOdDbOsnapOverrule_0(IntPtr protocolClass);

		public delegate IntPtr SwigDelegateOdDbOsnapOverrule_1();

		public delegate bool SwigDelegateOdDbOsnapOverrule_2(IntPtr pOverruledSubject);

		public delegate int SwigDelegateOdDbOsnapOverrule_3(IntPtr pSubject, int osnapMode, IntPtr gsSelectionMark, IntPtr pickPoint, IntPtr lastPoint, IntPtr xWorldToEye, IntPtr snapPoints);

		public delegate int SwigDelegateOdDbOsnapOverrule_4(IntPtr pSubject, int osnapMode, IntPtr gsSelectionMark, IntPtr pickPoint, IntPtr lastPoint, IntPtr xWorldToEye, IntPtr snapPoints, IntPtr insertionMat);

		public delegate bool SwigDelegateOdDbOsnapOverrule_5(IntPtr pSubject);
	}
}
